package com.pay.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.pay.entity.boss.Customer;
import com.pay.enums.UserType;
import com.pay.mapper.boss.CustomerBossMapper;
import com.pay.service.WxCustTypeService;

@Service("wxCustTypeService")
public class WxCustTypeServiceImpl implements WxCustTypeService{

	@Resource
	private CustomerBossMapper customerBossMapper;
	private static Map<String, UserType> map = new HashMap<String, UserType>();
	static{
		map.put("1000", UserType.SM);
		map.put("2001", UserType.ZYT);
		map.put("9999", UserType.YS);
		map.put("9998", UserType.YS);
		map.put("9997", UserType.YS);
		map.put("9990", UserType.YS);
		map.put("9991", UserType.YS);
		map.put("9992", UserType.YS);
		map.put("9993", UserType.YS);
	}

	@Override
	public UserType getCustTypeByCustomerNo(String customerNo) {
		Customer customer = customerBossMapper.findCustomerByCustomerNo(customerNo);
		if(customer != null){
			String mcc = customer.getMcc();
			UserType userType = map.get(mcc);
			if(userType!=null){
				return userType;
			}else{
				return UserType.POS;
			}
		}
		return UserType.POS;
	}
	@Override
	public UserType getCustTypeByMcc(String mcc) {
		UserType userType = map.get(mcc);
		if(userType!=null){
			return userType;
		}else{
			return UserType.POS;
		}
	}
	@Override
	public boolean productTypeCheck(String customerNo, String productNo) {
		Integer count = customerBossMapper.findCustProductCount(customerNo, productNo);
		if(count.intValue() > 0){
			return true;
		}else{
			return false;
		}
	}
}
